#include <cstdio>
#include <queue>
#include <vector>
#include <set>

typedef long long LL64;
const int coeff[3] = {2, 3, 5};

int main() {
  std::priority_queue<LL64, std::vector<LL64>, std::greater<LL64> > pq;
  std::set<LL64> set;
  pq.push(1);
  set.insert(1);

  int i, j, size = sizeof(coeff) / sizeof(*coeff);
  LL64 x, trans_x;
  for (i = 1; ; i++) {
    x = pq.top();
    pq.pop();
    if (i == 1500) {
      break;
    }
    
    for (j = 0; j < size; j++) {
      trans_x = coeff[j] * x;
      if (!set.count(trans_x)) {
        pq.push(trans_x);
        set.insert(trans_x);
      }
    }
  }

  std::printf("The 1500'th ugly number is %lld.\n", x);

  return 0;
}
